﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
using Microsoft.Office.Interop;
using Microsoft.Office.Interop.Word;

namespace RenShiPinYongBiao
{
    class WordPageBuilderTech : WordPageBuilder
    {
        public WordPageBuilderTech(DataSourceTech source, Application app):base(source,app)
        {

        }
        public override void BuildPage()
        {
            List<string> texts = source.PrepareText(index);
            Table t = doc.Tables[index + 1];
            t.Cell(1, 2).Range.Text = texts[0];
            t.Cell(1, 4).Range.Text = texts[1];
            t.Cell(1, 6).Range.Text = texts[2];
            t.Cell(1, 8).Range.Text = texts[3];
            t.Cell(2, 2).Range.Text = texts[4];
            t.Cell(2, 4).Range.Text = texts[5];
            t.Cell(2, 6).Range.Text = texts[6];
            t.Cell(2, 8).Range.Text = texts[7];
            t.Cell(3, 3).Range.Text = texts[8];
            t.Cell(3, 5).Range.Text = texts[9];
            t.Cell(4, 3).Range.Text = texts[10];
            t.Cell(4, 5).Range.Text = texts[11];
            t.Cell(5, 2).Range.Text = texts[12];
            t.Cell(6, 2).Range.Text = texts[13];
            t.Cell(6, 4).Range.Text = texts[14];
            t.Cell(7, 2).Range.Text = texts[15];
            t.Cell(8, 2).Range.Text = texts[16];
            if (source.Photo != null)
                System.Windows.Forms.Clipboard.SetImage(source.Photo);
            else
                System.Windows.Forms.Clipboard.SetText(" ");
            t.Cell(1, 9).Select();
            app.Selection.Paste();
            t.Cell(1, 9).Select();
            app.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            t.Cell(1, 9).VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter;
        }
    }
}
